<?php
if(!empty($_POST))
{
	$this->db->trans_start();
	foreach($_POST as $key => $value)
	{
		$sql = "update stock set jumlah = $value where tipe = '$key'";
		$this->db->query($sql);
	}
	$this->db->trans_complete();
	$this->session->set_flashdata('message', 'Data stock berhasil di update');
	redirect(base_url('report/stock'));
}
?>
<?php if(($message = $this->session->flashdata('message')) != null) { echo "<div class='message'>$message</div>"; } ?>
<form action="#" method="POST">
<div class="floatleft width750">
<h2 class="floatleft">Laporan Stock</h2>
<input class="floatright" style="margin-top: 25px;" type="submit" value="Update" />
</div>
<div class="width750 clear">
	<div class="border1 padding5 bgyellow" id="header">
		<span class="inline width250">Tipe</span>
		<span class="inline width150">Jumlah</span>
		<span class="inline width300">Update Terakhir</span>
	</div>
<?php
foreach($query as $row):
?>
	<div class="border1 padding5">
		<span class="inline width250"><?php echo $row->tipe;?></span>
		<span class="inline width150"><input class="width75" type="number" value="<?php echo $row->jumlah;?>" name="<?php echo $row->kode;?>" /></span>
		<span class="inline width300"><?php echo $row->waktu;?></span>
	</div>
<?php
endforeach;
?>
</div>
</form>